#ifndef GAMEVIEW_H
#define GAMEVIEW_H

#include <QWidget>
#include <QLabel>
#include <QPushButton>
#include <QMessageBox>
#include <QKeyEvent>
#include <QFile>
#include <QtGui>
#include<QVariant>
#include "algorithm.h"
#include "rankingview.h"
#include <iostream>

using namespace std;
namespace Ui {
class GameView;
}

class GameView : public QWidget
{
    Q_OBJECT

public:
    explicit GameView(QWidget *parent = 0);
    ~GameView();

    QString userName;
private:
    Ui::GameView *ui;
    QLabel *title;
    QLabel *scorelabel;
    QLabel *name;
    QPushButton *up;
    QPushButton *down;
    QPushButton *left;
    QPushButton *right;
    QPushButton *start;
    QPushButton *resetbtn;
    QPushButton *closebtn;
    void paintEvent(QPaintEvent *);//绘制游戏面板
    qreal w, h;//小格子的宽度和高度
    Algorithm algorithm;
    RankingView rankingview;
    int getBitCount(int);
    void scoreView();
    //按键控制
    void keyPressEvent(QKeyEvent * event);

    void dealRSignal();
    void dealESignal();


private slots:
     void newStart();
     void reset();
     void gridUp();   //点击up键
     void gridDown();   //点击down键
     void gridLeft();   //点击left键
     void gridRight();   //点击right键
};

#endif // GAMEVIEW_H
